package cn.lili.controller.goods;


import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.goods.entity.dos.Goods;
import cn.lili.modules.goods.entity.dos.GoodsHotPopular;
import cn.lili.modules.goods.entity.dto.GoodsHotPopularDTO;
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
import cn.lili.modules.goods.entity.vos.GoodsVO;
import cn.lili.modules.goods.service.GoodsHotPopularService;
import cn.lili.modules.goods.service.GoodsService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 爆款商品 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-02-27
 */

@RequestMapping("/goods/hotPopular")
@RequiredArgsConstructor
@Api(tags = "爆款商品-GoodsHotPopularController")
@RestController
public class GoodsHotPopularController {

    private final GoodsHotPopularService goodsHotPopularService;
    private final GoodsService goodsService;

    /**
     * 商品列表(用于-选择商品)
     * @param dto
     * @return
     */
    @GetMapping(value = "/selectGoodsList")
    @ApiOperation(value = "选择新品爆款商品列表")
    public ResultMessage<Page<Goods>> selectGoodsList(GoodsHotPopularDTO dto) {
        return ResultUtil.data(goodsService.selectGoodsList(dto));
    }



    @PostMapping(value = "/addHotPopularGoods")
    @ApiOperation(value = "PC端-添加新品爆款商品")
    @PreventDuplicateSubmissions
    public ResultMessage<Object> addHotPopularGoodsBatch(@RequestBody List<GoodsHotPopular> goodsHotPopularList) {
        return goodsHotPopularService.addHotPopularGoodsBatch(goodsHotPopularList);
    }

    @PostMapping(value = "/deleteHotPopularGoods")
    @ApiOperation(value = "PC端-删除新品爆款商品")
    @PreventDuplicateSubmissions
    public ResultMessage<Object> deleteHotPopularGoods(@RequestBody List<GoodsHotPopular> goodsHotPopularList) {
        return goodsHotPopularService.deleteHotPopularGoods(goodsHotPopularList);
    }

    @PostMapping(value = "/updateHotPopularGoods")
    @ApiOperation(value = "PC端-更新新品爆款商品")
    @PreventDuplicateSubmissions
    public ResultMessage<Object> updateHotPopularGoods(@RequestBody GoodsHotPopular goodsHotPopular) {
        return goodsHotPopularService.updateHotPopularGoods(goodsHotPopular);
    }

    @GetMapping(value = "/getHotPopularGoodsPageList")
    @ApiOperation(value = "PC端-分页获取新品爆款商品列表")
    public ResultMessage<Page<GoodsHotPopular>> getHotPopularGoodsPageList(GoodsHotPopularDTO goodsHotPopularDTO) {
        return ResultUtil.data(goodsHotPopularService.getHotPopularGoodsPageList(goodsHotPopularDTO));
    }

    @GetMapping(value = "/getHotPopularGoodsAppList")
    @ApiOperation(value = "APP-分页获取新品爆款商品列表")
    public ResultMessage<Page<GoodsVO>> getHotPopularGoodsAppList(GoodsHotPopularDTO goodsHotPopularDTO) {
        return ResultUtil.data(goodsHotPopularService.getHotPopularGoodsAppList(goodsHotPopularDTO));
    }



}
